package engine

import (
	"crawler/fetcher"
	"log"
)

func worker(r Request) (ParseResult, error) {
	// 1. 获取网页内容
	body, err := fetcher.Fetch(r.Url)
	if err != nil {
		log.Printf("Fetcher: error fetching url %s: %v\n", r.Url, err)
		return ParseResult{}, err
	}

	// 2. 解析网页内容
	return r.ParserFunc(body, r.Url), nil
}
